package com.zem.imos.Entity;


import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.fasterxml.jackson.annotation.JsonIgnore;


import com.zem.imos.Entity.Enum.Gender;
import com.zem.imos.Entity.Enum.Role;
import com.zem.imos.Entity.Params.ParamsAdmin;
import com.zem.imos.Entity.Params.ParamsDoctor;
import com.zem.imos.Entity.Params.ParamsPatient;
import com.zem.imos.Entity.Params.ParamsUser;
import lombok.Data;


@Data
public class User {

  @TableId(type = IdType.ASSIGN_ID)
  private Long id;
  private String username;
  @JsonIgnore
  private String password;
  private Gender gender;
  private String name;
  private String avatar;
  private Integer age;
  private Role role;
  @TableLogic
  @JsonIgnore
  private Integer isdeleted;
  private String phone;
  private String idNum;

  public User()
  {
  }
  public User (ParamsUser params)
  {
    this.id = params.getUserId();
    this.username = params.getUsername();
    this.password = params.getPassword();
    this.setGender(params.getGender());
    this.name = params.getName();
    this.avatar = params.getAvatar();
    this.age = params.getAge();
    this.setRole(params.getRole());
    this.phone = params.getPhone();
    this.idNum = params.getIdNum();
  }
  public User (ParamsDoctor params)
  {
    this.id = params.getUserId();
    this.username = params.getUsername();
    this.password = params.getPassword();
    this.setGender(params.getGender());
    this.name = params.getName();
    this.avatar = params.getAvatar();
    this.age = params.getAge();
    this.setRole(params.getRole());
    this.phone = params.getPhone();
    this.idNum = params.getIdNum();
  }



  public void setGender(Integer flag){
    switch (flag){
      case 0 :
        this.gender = Gender.Male;
        break; //可选
      case 1 :
        this.gender = Gender.Female;
        break; //可选
      default :
        this.gender = Gender.Male;
    }
  }

  public void setRole(Integer flag){
    switch (flag){
      case 0 :
        this.role = Role.Doctor;
        break; //可选
      case 1 :
        this.role = Role.Patient;
        break; //可选
      case 2 :
        this.role = Role.Admin;
        break; //可选
      default :
        this.role = Role.Patient;

    }
  }

}
